<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>


<script type="text/javascript"
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

<script type="text/javascript">


	$(function(){
		$("#boutonOperationCarte").click(function(){
				$("#test").toggleClass("classe_cache").toggleClass("tableau_comptes");
				$.post("${pageContext.request.contextPath}/client/compte/update.html", {etat:$("#test").attr('class')});

		});
	});
</script>


<div class="bandeau_titre">
	<div class="texte"><h1>Détail compte :</h1></div>
</div>
<br />
<br />


<form method="POST"	action="${pageContext.request.contextPath}/client/compte/${compte.id}/selection.html">
	<table>
		<tr>
			<td>mois :</td>
			<td><select name="moisChoisi">
					<c:forEach items="${calendrier}" var="mois">
						<option value="${mois.numero}"
							<c:if test="${mois.numero==selectedMonth}">selected</c:if>>
							<c:out value="${mois.nom}" />
						</option>
					</c:forEach>
			</select>
			</td>
			<td>année :</td>
			<td><select name="anneeChoisie">
					<c:forEach items="${calendrierAnnee}" var="annee">
						<option <c:if test="${annee==selectedYear }">selected</c:if>>
							<c:out value="${annee}" />
						</option>
					</c:forEach>
			</select>
			</td>
			<td><input type="submit" value="Valider"></td>
		</tr>
	</table>
</form>


<!-- TABLEAU DES COMPTES -->
<!-- Affiche toutes les données sur les operations en espece -->
<table class="tableau_comptes">
	<tr>
		<th colspan="3"><c:out value="${compte.nomCompte}" /> n°<c:out
				value="${compte.id}" /></th>
		<th>Solde actuel <br /> <span class="soldecourant"> <c:out
					value="${compte.soldeCourant}" /> € </span></th>
	</tr>
	<tr>
		<th width="5%">id</th>
		<th width="20%">Date Operation</th>
		<th width="55%">libelle</th>
		<th width="20%">montant</th>
	</tr>

	<c:forEach items="${operationsSansCarte}" var="operation">
		<tr>
			<td><c:out value="${operation.id}" /></td>
			<td><joda:format value="${operation.dateOperation}"
					pattern="dd-MM-yyyy" /></td>
			<td class="libelle"><c:out value="${operation.libelle}" /></td>
			<td><c:choose>
					<c:when test="${operation.montant<0}">
						<span class="textrouge"> <c:out
								value="${operation.montant}" /> €</span>
					</c:when>
					<c:otherwise>
						<c:out value="${operation.montant}" /> €
					</c:otherwise>
				</c:choose>
				</td>
		</tr>
	</c:forEach>
<c:if test="${hasOperationsSansCarte==true }">
	<tr class="ligne_pagination">
		<td colspan="4" style="text-align: center;">
			
				<c:if test="${numeroPage>1 }">
					<span class="pagination">
						<a href="${pageContext.request.contextPath}/client/compte/operationsCarte/${selectedMonth}/${selectedYear}/${compte.id}/${numeroPage-1}/${numeroPageCarte}.html"> &lt;</a>
					</span>
				</c:if>
				<c:forEach var="i" begin="1" end="${nbPages}">
					<span class="pagination">
					<a	href="${pageContext.request.contextPath}/client/compte/operationsCarte/${selectedMonth}/${selectedYear}/${compte.id}/${i}/${numeroPageCarte}.html">${i}</a>
					</span>
				</c:forEach>
				<c:if test="${numeroPage<nbPages }">
					<span class="pagination">
						<a href="${pageContext.request.contextPath}/client/compte/operationsCarte/${selectedMonth}/${selectedYear}/${compte.id}/${numeroPage+1}/${numeroPageCarte}.html">&gt;</a>
					</span>
				</c:if>
			
		</td>
	</tr>
	</c:if>
	<tr>
		<th colspan="3" align="right"><a href="#" id="boutonOperationCarte">+
				Total operation Cartes :</a>
		</th>
		<td><c:out value="${totalcartes}" /> €</td>
	</tr>
</table>

<!-- Tableau des operations CARTES -->
<table class="${stat2}" id="test">
	<tr>
		<th width="5%">id</th>
		<th width="20%">Date Operation</th>
		<th width="55%">libelle</th>
		<th width="20%">montant</th>
	</tr>
	<c:forEach items="${operationsCarte}" var="operation">
		<tr>
			<td><c:out value="${operation.id}" /></td>
			<td><joda:format value="${operation.dateOperation}"
					pattern="dd-MM-yyyy" /></td>
			<td class="libelle"><c:out value="${operation.libelle}" /></td>
			<td><c:choose>
					<c:when test="${operation.montant<0}">
						<span class="textrouge"> <c:out
								value="${operation.montant}" /> €</span>
					</c:when>
					<c:otherwise>
						<c:out value="${operation.montant}" /> €
					</c:otherwise>
				</c:choose>
			</td>
		</tr>
	</c:forEach>
	<tr class="ligne_pagination">
		<td colspan="4" style="text-align: center;"> 			
			<c:if test="${hasOperationsCarte==true }">
				<c:if test="${numeroPageCarte>1 }">
					<span class="pagination">
						<a href="${pageContext.request.contextPath}/client/compte/operationsCarte/${selectedMonth}/${selectedYear}/${compte.id}/${numeroPage}/${numeroPageCarte-1}.html"> &lt;</a>
					</span>
				</c:if>
				<c:forEach var="i" begin="1" end="${nombrePagesForCard}">
					<span class="pagination">
						<a	href="${pageContext.request.contextPath}/client/compte/operationsCarte/${selectedMonth}/${selectedYear}/${compte.id}/${numeroPage}/${i}.html">${i}</a>
					</span>
				</c:forEach>
				<c:if test="${numeroPageCarte<nombrePagesForCard}">
					<span class="pagination">
						<a  href="${pageContext.request.contextPath}/client/compte/operationsCarte/${selectedMonth}/${selectedYear}/${compte.id}/${numeroPage}/${numeroPageCarte+1}.html">&gt;</a>
					</span>
				</c:if>
			</c:if>
		</td>
	</tr>
</table>


<form
	action="${pageContext.request.contextPath}/client/compte/${compte.id}/mois.html"
	method="POST">

	<c:if test="${(hasOperationsSansCarte || hasOperationsCarte)==true }">
		<input type="hidden" value="${selectedMonth}" name="valeurMois" />
		<input type="hidden" value="${selectedYear}" name="valeurAnnee" />
		<input type="submit" id="operationsOnExcel"
			value="Telecharger liste des operations" />

	</c:if>

 </form>
		







